package one1;

/*class Alg1<T extends Comparable<T>> {
    public T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            *//*if (array[i] > max) {
                max = array[i];
            }*//*
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
                ;
            }
        }
        return max;
    }
}*/

class Alg1<T extends Comparable<T>> {
    public T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;
    }
}


class Alg2 {
    public <T extends Comparable<T>> T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;
    }
}

class Alg3 {
    public static <T extends Comparable<T>> T findMax(T[] array) {
        T max= array[0];
        for (int i = 0; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;

    }

}

public class Test2 {

    public static void main(String[] args) {
        Integer[] array = {1, 2, 3, 4, 5};
        Integer max = Alg3.<Integer>findMax(array);
        System.out.println(max);

    }

    public static void main2(String[] args) {
        Integer[] array = {1, 2, 3, 4, 5};
        Alg2 alg2 = new Alg2();
        Integer max = alg2.<Integer>findMax(array);
        System.out.println(max);
    }

    public static void main1(String[] args) {
        Integer[] array = {1, 2, 3, 4, 5};
        Alg1<Integer> alg1 = new Alg1<>();
        Integer max = alg1.findMax(array);
        System.out.println(max);
    }

    /*public static void main(String[] args) {
        Integer[] array = {1, 2, 3, 4};
        Alg1<Integer> alg = new Alg1<>();
        Integer max = alg.findMax(array);
        System.out.println(max);
    }*/
}
